﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace Cms.Core.Infrastructure.Helps
{
    public class ExpressionDataRowMappe<TOut> where TOut : class,new()
    {

        public static TOut SqlDataRowToModel(DataTable dataTable)
        {
            if (dataTable.Rows.Count > 0)
            {
                return GeneraterExpression<DataRow, TOut>._func(dataTable.Rows[0]);
            }

            return default(TOut);

        }

        public static IEnumerable<TOut> SqlDataRowToList(DataTable dataTable)
        {

            List<TOut> collection = new List<TOut>();

            foreach (DataRow row in dataTable.Rows)
            {
                collection.Add(GeneraterExpression<DataRow, TOut>._func(row));
        
            }

            return collection;
        }

     
    }
}
